
<div class="sidebar2">

<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar('sidebar 2') ) : else : ?>

 <h2>Popular</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 3"); 
foreach ($result as $post) { 
setup_postdata($post);
$postid = $post->ID; 
$title = $post->post_title; 
$commentcount = $post->comment_count; 
if ($commentcount != 0) { ?> 

<li> 
<em><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>"><?php echo $title ?></a> </em>
</li>

<li>
<a href="<?php echo get_permalink($postid); ?>#respond" title="<?php echo $title ?>"> 
<img src="<?php $key="article_image"; echo get_post_meta($post->ID, $key, true); ?>" alt="<?php echo $title ?>" class="right" width="24" height="24" /> 
{<?php echo $commentcount ?>}</a>
</li> 

<?php } } ?>
			</ul>


	<?php endif; ?>

</div>